<template>
	<view class="OrderList">
		<!-- <view class="headtop">
			<view :class="act==0?'act':'title'" @click="tabs(0)">
				全部
			</view>
			<view :class="act==1?'act':'title'" @click="tabs(1)">
				待发货
			</view>
			<view :class="act==4?'act':'title'" @click="tabs(4)">
				待支付
			</view>
			<view :class="act==2?'act':'title'" @click="tabs(2)">
				已发货
			</view>
			<view :class="act==3?'act':'title'" @click="tabs(3)">
				已完成
			</view>
		</view> -->
		<!-- <view class="content_list">
			<view class="item">
				<view class="top">
					<view class="name">
						中国石化潍坊加油一站
					</view>
					<view class="time">
						{{'2021.10.1000:00:00' | time}}
					</view>
				</view>
				<view class="content">
					<view class="left">
						<image src="../../static/tabsIcon/youzhan.png" class="goods" mode=""></image>
						<view class="mid">
							<view class="sh">
								<text>油号：92#</text>
								<text>枪号：4</text>
							</view>
							<view class="xia">
								<text>加油金额：￥100</text>
							</view>
						</view>
					</view>
					<view class="right">
						<text class="qian">实付:￥</text>
						<text class="hou">90.00</text>
					</view>
				</view>
			</view>
		</view> -->
		
		<view class="content_list">
			<view v-for="(item,index) in goodslists" class="item">
				<view class="top">
					<view class="name">
						{{item.gasName}}
					</view>
					<view class="time">
						{{item.payTime | time}}
					</view>
				</view>
				<view class="content">
					<view class="left">
						<image src="../../static/tabsIcon/youzhan.png" class="goods" mode=""></image>
						<view class="mid">
							<view class="sh">
								<text style="margin-right: 20rpx;">油号：{{item.oilNo}}</text>
								<text>枪号：{{item.gunNo}}</text>
							</view>
							<view class="xia">
								<text>加油金额：￥{{item.amountGun}}</text>
							</view>
						</view>
					</view>
					<view class="right">
						<text class="qian">实付:￥</text>
						<text class="hou">{{item.amountPay}}</text>
					</view>
				</view>
				<view class="sta">
					{{item.orderStatusName}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		platformOrderInfoV2
	} from '@/api/orderlist'
	export default {
		data() {
			return {
				act: 0,
				lists: {
					goodsName: null,
					orderStatus: null,
					logisticsStatus: null,
					pageSize: 10,
					pageIndex: 1,
				},
				goodslists: [],
			}
		},
		filters:{
			time(text){
				let str = text.slice(0,10)
				return str
			}
		},
		onReachBottom() {
			this.lists.pageIndex++;
			this.goodslist()
		},
		created() {
			this.goodslist();
		},
		methods: {
			jump(item) {
				if (item.orderStatusStr == '待支付') {
					uni.navigateTo({
						url: '/pages/index/payment/payment?id=' + item.id
					});
				} else {
					uni.navigateTo({
						url: "/pages/index/detail/detail?id=" + item.goodsId,
					});
				}
			},
			goodslist() {
				platformOrderInfoV2(this.lists).then(res => {
					console.log(res)
					if (res.code == 200 && res.totalRow != 0) {
						console.log(res.result)
						for (let sss in res.result) {
							this.goodslists.push(res.result[sss])
						}

					} else {
						this.lists.pageIndex--;
						uni.showToast({
							title: '无更多订单',
							icon: 'none',
							duration: 2000
						});
					}
				}).catch(res => {
					console.log(res)
					this.lists.pageIndex--;
				})
			},
			tabs(i) {
				this.act = i;
				if (i == 0) {
					// 全部
					this.lists.goodsName = null;
					this.lists.orderStatus = null;
					this.lists.logisticsStatus = null;
					this.lists.pageSize = 10;
					this.lists.pageIndex = 1;
				} else if (i == 1) {
					// 待发货
					this.lists.goodsName = null;
					this.lists.orderStatus = null;
					this.lists.logisticsStatus = 1;
					this.lists.pageSize = 10;
					this.lists.pageIndex = 1;
				} else if (i == 2) {
					// 已发货
					this.lists.goodsName = null;
					this.lists.orderStatus = null;
					this.lists.logisticsStatus = 2;
					this.lists.pageSize = 10;
					this.lists.pageIndex = 1;
				} else if (i == 3) {
					// 已完成
					this.lists.goodsName = null;
					this.lists.orderStatus = null;
					this.lists.logisticsStatus = 3;
					this.lists.pageSize = 10;
					this.lists.pageIndex = 1;
				} else if (i == 4) {
					// 待付款
					this.lists.goodsName = null;
					this.lists.orderStatus = 0;
					this.lists.logisticsStatus = null;
					this.lists.pageSize = 10;
					this.lists.pageIndex = 1;
				}
				this.goodslists = [];
				this.goodslist();
			}
		},
		onLoad(option) {

		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #e7e9ec;
		padding: 0;
		margin: 0;
		// background-color: #18BC37;
	}

	.OrderList {
		// padding: 30rpx;
		padding: 0;
		margin: 0;
	}

	.headtop {
		position: fixed;
		width: 100%;
		display: flex;
		align-items: center;
		text-align: center;
		justify-content: space-around;
		// padding-bottom: 40upx;
		height: 120upx;
		z-index: 100;
		background-color: #e7e9ec;

		.title {
			color: rgba(0, 0, 0, 0.5);
			font-size: 28rpx;
		}

		.act {
			color: rgba(0, 0, 0, 0.9);
			font-size: 34rpx;
		}
	}

	.content_list {
		padding: 30rpx;
		// margin-top: 20rpx;
		// padding-top: 120rpx;

		.item {
			margin-bottom: 20rpx;
			padding: 30rpx;
			background: #FFFFFF;
			border-radius: 36rpx;

			.top {
				display: flex;
				align-items: flex-start;
				justify-content: space-between;

				.time {
					color: rgba(195, 195, 195, 0.9);
					font-size: 22rpx;
				}
			}

			.content {
				margin: 20rpx 0;
				padding: 20rpx 0;
				border-top: 1rpx solid rgba(0, 0, 0, 0.1);
				border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
				display: flex;
				justify-content: space-between;
				align-items: center;

				image {
					width: 90rpx;
					height: 90rpx;
					border-radius: 10rpx;
					margin-right: 30rpx;
				}
				
				.left{
					display: flex;
				}

				.mid {
					height: 90rpx;
					font-size: 22rpx;
					color: rgba(0, 0, 0, 0.5);
					display: flex;
					justify-content: space-between;
					flex-direction: column;
				}

				.right {
					height: 90rpx;
					line-height: 130rpx;

					.qian {
						font-size: 34rpx;
					}

					.hou {
						font-size: 50rpx;
					}
				}
			}

		}
	}
	.sta{
		text-align: right;
		font-size: 28rpx;
		color: red;
	}
</style>